# -*- coding: utf-8 -*-
"""
@date: 2020/12/4 16:02
@file: io.py
@author: lilong
@desc: 数据流
"""

import pickle


def load_vocab(vocab_path):
    """加载.pkl格式的文件"""
    with open(vocab_path, "rb") as f:
        return pickle.load(f)


def saveVocabPkl(vocab_txt, vocab_path):
    """保存txt文件为.pkl"""
    ll = []
    with open(vocab_txt, "r", encoding="utf-8") as f:
        for line in f.readlines():
            ll.append(line.strip())
    with open(vocab_path, "wb") as f:
        pickle.dump(ll, f)
